package com.daifeng.gulimall.product.web;

import com.daifeng.gulimall.product.entity.CategoryEntity;
import com.daifeng.gulimall.product.service.CategoryService;
import com.daifeng.gulimall.product.vo.category2Vo;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;
import java.util.Map;

@Controller
public class webRooterController {

    @Autowired
    CategoryService categoryService;

    @RequestMapping({"/","/index","home"})
    public String index(Model model){
       List<CategoryEntity> categoryEntityList =  categoryService.getAllOFLevel1();
       model.addAttribute("categoryList",categoryEntityList);
        return "home";
    }


    @ResponseBody
    @RequestMapping("index/catalog.json")
    public Map<String,List<category2Vo>> catalogJson(){
        Map<String,List<category2Vo>> map = categoryService.getcatalogJson();
        return map;

    }

}
